
#pragma once

#include <cstring>
#include <string>
#include <sstream>
#include <map>
#include <vector>

enum EmHttpParseStatus
{
	EmParseInit,		// init status
	EmParseLine,		// parse http line status 
	EmParseHeader,		// parse http header status
	EmParseBody,		// parse http body data
	EmParseFinish,		// finish http data parse
	EmParseFail         // parse fail status
};

struct HttpRequestParam
{
	std::string m_method;
	std::string m_uri;
	std::string m_http_version;

	std::map<std::string, std::vector<std::string>> m_header_map;
	int         m_body_length{0};
	std::vector<char> m_body_data;
	EmHttpParseStatus m_http_request_status{EmParseInit};
};


struct HttpResponseParam
{
	std::string m_method;
	std::string m_uri;
	std::string m_http_version;

	std::map<std::string, std::vector<std::string>> m_header_map;
	int         m_body_length{0};
	std::vector<char> m_body_data;
};


int ParseHttpData(const char * data, int length, HttpRequestParam & http_param);
int ParseHttpData(const char * data, int length, HttpResponseParam & http_param);

